<template>
  <div>
    <h2>添加部门</h2>部门名称
    <input type="text" v-model="name" />
    <button @click="sub">添加部门</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: ""
    };
  },
  methods: {
    sub: function() {
      let auth = localStorage.getItem("auth");
      let data = {
        name: this.name,
        auth: auth
      };

      this.axios({
        url: "http://127.0.0.1:8000/app01/department/",
        method: "post",
        data: data
      }).then(res => {
        if (res.data.code == 1000) {
          //
          this.$router.push("/user");
        } else {
          alert(res.data.msg);
        }
      });
    }
  }
};
</script>

<style>
</style>